﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;

public partial class Admin_Product_ProductAdd : BLL.AdminPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //BLL.DDLManage.BindProductType(ddlType);
        }
    }
    protected void btnsave_Click(object sender, ImageClickEventArgs e)
    {
        //try
        //{
        //    T_Product product = new T_Product();
        //    //product.ProductName = txtProductName.Text;
        //    //product.PhotoName = hfImg.Value;
        //    //product.Introduce = txtIntro.Text;
        //    //product.Author = txtAuthor.Text;
        //    //product.Years = txtYears.Text;
        //    //product.Size = txtSize.Text;
        //    //product.Price = txtPrice.Text;
        //    //product.PTID = Convert.ToInt32(ddlType.SelectedValue);
        //    ctx.T_Product.InsertOnSubmit(product);
        //    ctx.SubmitChanges();
        //    Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('操作成功!');", true);
        //}
        //catch (Exception)
        //{
        //    Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('操作失败!');", true);
        //}
        try
        {
            T_Product product = new T_Product();
            product.ProductTitle = txtTitle.Text;
            product.ProductAbout = txtAbout.Text;
            product.CoverIMG = hfImg.Value;
            product.ProductDetails = txtDetails.Text;
            product.ProductDetailsIMG = hfImg1.Value;
            product.StartPrice = txtStartPrice.Text;
            product.CurrentPrice = txtStartPrice.Text;
            product.StartTime = Convert.ToDateTime(txtStartTime.Text);
            product.EndTime = Convert.ToDateTime(txtEndTime.Text);
            if (DateTime.Now > product.StartTime)
            {
                product.Status = 1;
            }
            else
            {
                product.Status = 0;
            }
            ctx.T_Product.InsertOnSubmit(product);
            ctx.SubmitChanges();
            Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('操作成功!');", true);
        }
        catch (Exception)
        {

            Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('操作失败!');", true);
        }
    }
}